# Vul hier uw domeinnaam in als gebruikersnaam (:user)
# en de server zoals deze in uw email stond als
# applicatienaam (:application) in waarop de applicatie komt te draaien

set :user, "huisrekening.vanutsteen.nl"
set :application, "s009831.railsnet.nl"
# Vul hier de locatie in van uw SVN repository
# waar de code van het project staat
# (alleen indien van toepassing).
set :repository, "http://huisrekening.googlecode.com/svn/trunk"

#Added by Leon
set :synchronous_connect, true

# Byte Defaults, should work!
default_run_options[:pty] = true
set :deploy_to, "~"
set :use_sudo, false
set :group_writable, false

set :deploy_via, :export
#set :deploy_via, :copy
#set :copy_strategy, :export

# Byte manages the location of your mongrel instances, so
# the only machine here is the deployment system. Do NOT change
# for example the :db role to the database system you use
# in your config/database.yml

role :web, application
role :app, application
role :db,  application, :primary => true

# Byte Tasks, don't edit these unless you know what you are doing!

# Use the Byte mongrel manager. You cannot start your Mongrels using
# the standard Mongrel recipes, so don't remove this task!
namespace :deploy do
  task :start, :roles => :app do
    sudo "mongrel_manager start", :as => "manager"
  end
  task :stop, :roles => :app do
    sudo "mongrel_manager stop", :as => "manager"
  end
  task :restart, :roles => :app do
    sudo "mongrel_manager restart", :as => "manager"
  end

  task :default do
    update
    backgroundrb.restart
    restart
  end
  
  task :after_deploy do
    copy_user_images
  end

  # Task for setup of the new version after a manual upload. This is useful
  # for people deploying from Windows who don't have tar / ssh / scp / svn
  # available. The procedure is to first upload the new version to ~/new
  # and after that to run this task. This will copy the ~/new directory
  # to the timestamp format in ~/releases, fix permissions for Apache,
  # update the log symlink, update the current symlink and restart the
  # mongrel processes.
  task :uploaded do
    transaction do
      stamp = Time.now.strftime("%Y%m%d%H%M%S")
      run "cp -r ~/new #{releases_path}/#{stamp}"
      finalize_update
      symlink
      backgroundrb.restart
      restart
    end
  end
  namespace :backgroundrb do
    task :start do
      run "backgroundrb_manager start"
    end
    task :stop  do
      run "backgroundrb_manager stop"
    end

    task :restart do
      stop
      start
    end
  end
end

namespace :deploy do  
  desc "Link in the production database.yml" 
  task :after_update_code do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 
  end
  
  task :copy_user_images do
    run "cp #{previous_release}/public/images/users/*.jpg   current/public/images/users/"
  end
end